
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import 'frame_animation_image.dart';


void main()=>runApp(new MaterialApp(home:Frame()));

class Frame extends StatelessWidget {

  bool b = false;

  final List<String> list = [
    'https://upload-images.jianshu.io/upload_images/17539976-746f3b1e50058aa0.png?imageMogr2/auto-orient/strip|imageView2/2/w/210/format/webp',
    'https://upload-images.jianshu.io/upload_images/17539976-0302150ef7230b71.png?imageMogr2/auto-orient/strip|imageView2/2/w/210/format/webp',
    'https://upload-images.jianshu.io/upload_images/17539976-cbf5c91b90c0805a.png?imageMogr2/auto-orient/strip|imageView2/2/w/210/format/webp',
    'https://upload-images.jianshu.io/upload_images/17539976-138a6be2798465b4.png?imageMogr2/auto-orient/strip|imageView2/2/w/210/format/webp',

  ];
  final GlobalKey<FrameAnimationImageState> _cotroller = new GlobalKey<FrameAnimationImageState>();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text('帧动画'),
          centerTitle: true,
        ),
        body: Column(
          children: <Widget>[
            Center(
              child: GestureDetector(
                onTap: () {
                  if (b) {
                    _cotroller.currentState?.reStartAnimation();
                  } else {
                    _cotroller.currentState?.startAnimation();
                  }

                  b = !b;
                },
                child: FrameAnimationImage(_cotroller, list,
                    width: 220, height: 200, interval: 5000, start: true),
              ),
            ),
          ],
        )

    );
  }

}